package cn.kongwg.juc;

/**
 * @author kongwg
 * @create 2021-05-03 15:05
 */

import cn.kongwg.juc.entry.User;

import java.util.Arrays;
import java.util.Comparator;
import java.util.List;

/**
 * 找出满足
 * 偶数Id 且年龄大于24 且用户名转为大写且用户名字母倒排序
 * 只输出一个名字  E
 */
public class StreamDemo {
    public static void main(String[] args) {
        User user1 = new User(11, "a", 23);
        User user2 = new User(12, "b", 24);
        User user3 = new User(13, "c", 22);
        User user4 = new User(14, "d", 28);
        User user5 = new User(16, "e", 26);
        List<User> list = Arrays.asList(user1, user2, user3, user4, user5);
        list.stream().filter((user) -> {
            return user.getId() % 2 == 0 && user.getAge() > 24;
        }).map((user) -> {
            return user.getName().toUpperCase();
        }).sorted((o1, o2) -> {
            return o2.compareTo(o1);
        }).limit(1).forEach(System.out::println);
    }
}
